package com.selfdriving.activity;

import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.FrameLayout;
import android.widget.RadioButton;

import com.selfdriving.R;
import com.selfdriving.dialog.FilterDialog;

public class WAAmbitusPageActivity extends ActivityGroup implements
		OnCheckedChangeListener
{
	private FrameLayout container = null;
	private Intent intent1;
	private Intent intent2;
	private FilterDialog filterDialog;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.w_a_ambitus_page);
		intent1 = new Intent(WAAmbitusPageActivity.this,
				WAAmbitusServiceList.class);
		intent2 = new Intent(WAAmbitusPageActivity.this,
				WAAmbitusServiceVIP.class);
		init();
		filterDialog = new FilterDialog(this);
	}

	public void init()
	{
		container = (FrameLayout) findViewById(R.id.tabcontent);
		RadioButton btnModule1 = (RadioButton) findViewById(R.id.tab_item_1);
		btnModule1.setOnCheckedChangeListener(this);
		RadioButton btnModule2 = (RadioButton) findViewById(R.id.tab_item_2);
		btnModule2.setOnCheckedChangeListener(this);
		btnModule1.setChecked(true);
	}

	@Override
	public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
	{
		if (isChecked)
		{
			container.removeAllViews();
			switch (buttonView.getId())
			{
			case R.id.tab_item_1:
				container.addView(getLocalActivityManager().startActivity("1",
						intent1).getDecorView());
				break;
			case R.id.tab_item_2:
				container.addView(getLocalActivityManager().startActivity("2",
						intent2).getDecorView());
				break;
			}
		}
	}

	@Override
	public boolean dispatchKeyEvent(KeyEvent event)
	{
		if ((event.getAction() == KeyEvent.ACTION_DOWN)
				&& (event.getKeyCode() == KeyEvent.KEYCODE_BACK))
		{

		}
		return super.dispatchKeyEvent(event);
	}

}
